/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.una.accidentmanagement.view;

import br.com.una.accidentmanagement.model.Status;
import br.com.una.accidentmanagement.model.Ticket;
import br.com.una.accidentmanagement.view.manipulator.TicketTable;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author santosmgbh
 */
public class CustomTableCellRenderer extends DefaultTableCellRenderer implements TableCellRenderer { 
    
    private TicketTable ticketTable;

    public CustomTableCellRenderer(TicketTable ticketTable) {
        this.ticketTable = ticketTable;
    }
    
    

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);        
        Ticket ticket = ticketTable.getTicketByIndex(row);
        switch(ticket.getStatus()){
            case EMABERTO:
                setBackground(Color.GREEN);
                break;
            case EMATENDIMENTO:
                setBackground(Color.decode("#00CCFF"));
                break;
            case FINALIZADO:
                setBackground(Color.GRAY);
                break;
        }        
        return this;
    }
    
    
    
}
